package org.loong.crypto.core.params;

import java.security.Key;

import org.loong.crypto.core.Parameters;

/**
 * The parameters to message digest of sm3 algorithm.
 */
public class MessageDigestParameters implements Parameters {

    /**
     * The key.
     */
    private Key key;

    /**
     * The key bytes.
     */
    private byte[] keyBytes;

    /**
     * The id.
     */
    private byte[] id;

    /**
     * no args constructor.
     */
    public MessageDigestParameters() {}

    /**
     * builder constructor.
     *
     * @param builder builder
     */
    private MessageDigestParameters(final Builder builder) {
        this.key = builder.key;
        this.keyBytes = builder.keyBytes;
        this.id = builder.id;
    }

    /**
     * class builder.
     *
     * @return builder
     */
    public static Builder builder() {
        return new Builder();
    }

    /**
     * Gets the value of key.
     *
     * @return the value of key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key the key to set
     */
    public void setKey(final Key key) {
        this.key = key;
    }

    /**
     * Gets the value of keyBytes.
     *
     * @return the value of keyBytes
     */
    public byte[] getKeyBytes() {
        return keyBytes;
    }

    /**
     * Sets the keyBytes.
     *
     * @param keyBytes the keyBytes to set
     */
    public void setKeyBytes(final byte[] keyBytes) {
        this.keyBytes = keyBytes;
    }

    /**
     * Gets the value of id.
     *
     * @return the value of id
     */
    public byte[] getId() {
        return id;
    }

    /**
     * Sets the id.
     *
     * @param id the id to set
     */
    public void setId(final byte[] id) {
        this.id = id;
    }

    /**
     * class builder.
     */
    public static final class Builder {

        private Key key;

        private byte[] keyBytes;

        private byte[] id;

        /**
         * no args constructor.
         */
        private Builder() {}

        /**
         * build new Object.
         *
         * @return this
         */
        public MessageDigestParameters build() {
            return new MessageDigestParameters(this);
        }

        /**
         * build key.
         *
         * @param key key
         * @return this
         */
        public Builder key(final Key key) {
            this.key = key;
            return this;
        }

        /**
         * build keyBytes.
         *
         * @param keyBytes keyBytes
         * @return this
         */
        public Builder keyBytes(final byte[] keyBytes) {
            this.keyBytes = keyBytes;
            return this;
        }

        /**
         * build id.
         *
         * @param id id
         * @return this
         */
        public Builder id(final byte[] id) {
            this.id = id;
            return this;
        }
    }
}
